home *** CD-ROM | disk | FTP | other *** search
/ ADA Programming Guide / ADA Programming Guide.iso / ada_gnu / adainc / s-os2thr.ads < prev    next >
Text File  |  1996-01-30  |  7KB  |  163 lines

  1. ------------------------------------------------------------------------------
  2. --                                                                          --
  3. --                 GNU ADA RUNTIME LIBRARY (GNARL) COMPONENTS               --
  4. --                                                                          --
  5. --                 S Y S T E M . O S 2 L I B . T H R E A D S                --
  6. --                                                                          --
  7. --                                  S p e c                                 --
  8. --                                                                          --
  9. --                             $Revision: 1.4 $                             --
  10. --                                                                          --
  11. --             Copyright (c) 1993,1994 NYU, All Rights Reserved             --
  12. --                                                                          --
  13. --  GNARL is free software; you can redistribute it and/or modify it  under --
  14. --  terms  of  the  GNU  Library General Public License as published by the --
  15. --  Free Software Foundation; either version 2,  or (at  your  option)  any --
  16. --  later  version.   GNARL is distributed in the hope that it will be use- --
  17. --  ful, but but WITHOUT ANY WARRANTY; without even the implied warranty of --
  18. --  MERCHANTABILITY  or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Gen- --
  19. --  eral Library Public License for more details.  You should have received --
  20. --  a  copy of the GNU Library General Public License along with GNARL; see --
  21. --  file COPYING. If not, write to the Free Software Foundation,  675  Mass --
  22. --  Ave, Cambridge, MA 02139, USA.                                          --
  23. --                                                                          --
  24. ------------------------------------------------------------------------------
  25.  
  26. with Interfaces.C; use Interfaces.C;
  27.  
  28. package System.OS2Lib.Threads is
  29. pragma Preelaborate (Threads);
  30.  
  31.    type PID is new unsigned_long;
  32.    type PPID is access all PID;
  33.    --  Process ID, and pointer to process ID
  34.  
  35.    type TID is new unsigned_long;
  36.    type PTID is access all TID;
  37.    --  Thread ID, and pointer to thread ID
  38.  
  39.    -------------------------------------------------------------
  40.    -- Thread Creation, Activation, Suspension And Termination --
  41.    -------------------------------------------------------------
  42.  
  43.    --  Note: <bsedos.h> defines the "Informations" and "param" parameter below
  44.    --  as a ULONG, but everyone knows that in general an address will be passed
  45.    --  to it. We declared it here with type PVOID (which it should have had)
  46.    --  because Ada is a bit more sensitive to mixing integers and addresses.
  47.  
  48.    type PFNTHREAD is access procedure (Informations : System.Address);
  49.    --  TBSL should use PVOID instead of Address as per above node ???
  50.  
  51.    function DosCreateThread
  52.      (F_ptid  : PTID;
  53.       pfn     : PFNTHREAD;
  54.       param   : PVOID;
  55.       flag    : ULONG;
  56.       cbStack : ULONG)
  57.       return    APIRET;
  58.    pragma Import (C, DosCreateThread, Link_Name => "DosCreateThread");
  59.  
  60.    Block_child     : constant := 1;
  61.    No_Block_child  : constant := 0;
  62.    Commit_stack    : constant := 2;
  63.    No_Commit_stack : constant := 0;
  64.    --  Values for "flag" parameter in DosCreateThread call
  65.  
  66.    procedure DosExit (Action : ULONG; Result : ULONG);
  67.    pragma Import (C, DosExit, Link_Name => "DosExit");
  68.  
  69.    EXIT_THREAD  : constant := 0;
  70.    EXIT_PROCESS : constant := 1;
  71.    --  Values for "Action" parameter in Dos_Exit call
  72.  
  73.    function DosResumeThread (Id : TID) return APIRET;
  74.    pragma Import (C, DosResumeThread, Link_Name => "DosResumeThread");
  75.  
  76.    function DosSuspendThread (Id : TID) return APIRET;
  77.    pragma Import (C, DosSuspendThread, Link_Name => "DosSuspendThread");
  78.  
  79.    procedure DosWaitThread (Thread_Ptr : PTID; Option : ULONG);
  80.    pragma Import (C, DosWaitThread, Link_Name => "DosWaitThread");
  81.  
  82.    DCWW_WAIT   : constant := 0;
  83.    DCWW_NOWAIT : constant := 1;
  84.    --  Values for "Option" parameter in DosWaitThread call
  85.  
  86.    ---------------------------------------------------
  87.    -- Accessing properties of Threads and Processes --
  88.    ---------------------------------------------------
  89.  
  90.    --  Structures translated from BSETIB.H
  91.  
  92.    --  Thread Information Block (TIB)
  93.    --  Need documentation clarifying distinction between TIB, TIB2 ???
  94.  
  95.    type TIB2 is record
  96.       tib2_ultid        : ULONG;  -- Thread I.D.
  97.       tib2_ulpri        : ULONG;  -- Thread priority
  98.       tib2_version      : ULONG;  -- Version number for this structure
  99.       tib2_usMCCount    : USHORT; -- Must Complete count
  100.       tib2_fMCForceFlag : USHORT; -- Must Complete force flag
  101.    end record;
  102.  
  103.    type PTIB2 is access all TIB2;
  104.  
  105.    --  Thread Information Block (TIB)
  106.  
  107.    type TIB is record
  108.       tib_pexchain      : PVOID;  -- Head of exception handler chain
  109.       tib_pstack        : PVOID;  -- Pointer to base of stack
  110.       tib_pstacklimit   : PVOID;  -- Pointer to end of stack
  111.       tib_ptib2         : PTIB2;  -- Pointer to system specific TIB
  112.       tib_version       : ULONG;  -- Version number for this TIB structure
  113.       tib_ordinal       : ULONG;  -- Thread ordinal number
  114.    end record;
  115.  
  116.    type PTIB is access all TIB;
  117.  
  118.    --  Process Information Block (PIB)
  119.  
  120.    type PIB is record
  121.       pib_ulpid         : ULONG;   -- Process I.D.
  122.       pib_ulppid        : ULONG;   -- Parent process I.D.
  123.       pib_hmte          : ULONG;   -- Program (.EXE) module handle
  124.       pib_pchcmd        : PCHAR;   -- Command line pointer
  125.       pib_pchenv        : PCHAR;   -- Environment pointer
  126.       pib_flstatus      : ULONG;   -- Process' status bits
  127.       pib_ultype        : ULONG;   -- Process' type code
  128.    end record;
  129.  
  130.    type PPIB is access all PIB;
  131.  
  132.    function DosGetInfoBlocks
  133.      (Pptib : access PTIB;
  134.       Pppib : access PPIB)
  135.       return  APIRET;
  136.    pragma Import (C, DosGetInfoBlocks, Link_Name => "DosGetInfoBlocks");
  137.  
  138.    -----------------
  139.    --  Priorities --
  140.    -----------------
  141.  
  142.    function DosSetPriority
  143.      (Scope   : ULONG;
  144.       Class   : ULONG;
  145.       Delta_P : long;
  146.       PorTid  : TID)
  147.       return    APIRET;
  148.    pragma Import (C, DosSetPriority, Link_Name => "DosSetPriority");
  149.  
  150.    PRTYS_PROCESS     : constant := 0;
  151.    PRTYS_PROCESSTREE : constant := 1;
  152.    PRTYS_THREAD      : constant := 2;
  153.    --  Values for "Scope" parameter in DosSetPriority call
  154.  
  155.    PRTYC_NOCHANGE         : constant := 0;
  156.    PRTYC_IDLETIME         : constant := 1;
  157.    PRTYC_REGULAR          : constant := 2;
  158.    PRTYC_TIMECRITICAL     : constant := 3;
  159.    PRTYC_FOREGROUNDSERVER : constant := 4;
  160.    --  Values for "class" parameter in DosSetPriority call
  161.  
  162. end System.OS2Lib.Threads;
  163.